<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>划线动态</title>
  <style>
    div {
      position: relative;
      display: inline-block;
    }

    input {
      outline: none;
      border: none;
      background: pink;
    }

    input~span {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 0;
      height: 1px;
      background-color: #262626;
      transform: scaleX(0);
      transform-origin: top center;
      transition: transform 0.3s ease-in-out;
    }

    input:focus~span {
      transform: scaleX(1);
      transform-origin: left center;
    }
  </style>
</head>

<body>
  <div>
    <input type="text" />
    <span></span>
  </div>

</body>

</html>